<?php
declare (strict_types = 1);

namespace app\validate;

use think\Validate;

class PhoneRegister extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'phone' => 'require|number|min:11|max:11|mobile|unique:user',
        'code' => 'require|number|min:4|max:4',
        'password' => 'require|min:6|max:18'
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'phone.require' => '请输入手机号',
        'phone.number' => '请输入正确的手机号',
        'phone.min' => '请输入正确的手机号',
        'phone.max' => '请输入正确的手机号',
        'phone.mobile' => '手机号不可用',
        'phone.unique' => '手机号已注册',
        'code.require' => '请输入验证码',
        'code.number' => '验证码错误',
        'code.min' => '验证码错误',
        'code.max' => '验证码错误',
        'password.require' => '请输入密码',
        'password.min' => '密码少于6位',
        'password.max' => '密码超出18位',
    ];
}
